package org.mclll.xwangplugin.mclllFix.listener;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.mclll.xwangplugin.MclllCustom;

/**
 * @author llB
 * @date 2024-07-09 21:30
 * @description todo
 */
public class ChatListener implements Listener {

    private MclllCustom plugin;

    public ChatListener(MclllCustom plugin) {
           this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onPlayerChat(final AsyncPlayerChatEvent event) {
        String message = event.getMessage();
        if (message.contains("陨铁") && message.contains("不")) {
            Bukkit.getScheduler().runTask(plugin, () -> {
                Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "tellraw @a [\"\",{\"text\":\"\\u3010\"},{\"text\":\"\\u7cfb\\u7edf\",\"bold\":true,\"color\":\"red\"},{\"text\":\"\\u3011\"},{\"text\":\"\\u914d\\u65b9\\u91cd\\u8f7d\\u4e2d.......\\u8bf7\\u7a0d\\u540e\\u5c1d\\u8bd5\\u9668\\u94c1\\u80fd\\u5426\\u7145\\u70e7\",\"color\":\"dark_green\"}]");
                Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "cc reload");
            });
        }
    }
}
